﻿using AutoMapper;
using RxxAdmin.Model.Entity;
using RxxAdmin.Model.ViewModels;

namespace RxxAdmin.Extensions;

public class CustomProfile : Profile
{
    /// <summary>
    /// 配置构造函数，用来创建关系映射
    /// </summary>
    public CustomProfile()
    {
        CreateMap<SysUser, SysUserPageOut>()
             .ForMember(a => a.id, o => o.MapFrom(d => d.Id))
             .ForMember(a => a.Account, o => o.MapFrom(d => d.LoginName))
             .ForMember(a => a.Name, o => o.MapFrom(d => d.RealName));
        CreateMap<SysUserPageOut, SysUser>()
            .ForMember(a => a.Id, o => o.MapFrom(d => d.id))
             .ForMember(a => a.LoginName, o => o.MapFrom(d => d.Account))
             .ForMember(a => a.RealName, o => o.MapFrom(d => d.Name));

        CreateMap<SysUserAddAndUpIn,SysUser>()
             .ForMember(a => a.LoginName, o => o.MapFrom(d => d.Account))
             .ForMember(a => a.RealName, o => o.MapFrom(d => d.Name));       
    }
}
